/**
 * 版权所有(C)，上海海鼎信息工程股份有限公司，2007，所有权利保留。
 * 
 * 项目名：	rumba
 * 文件名：	SysclockSubject.java
 * 模块说明：	
 * 修改历史：
 * Nov 10, 2007 - lxm - 创建。
 */
package com.hd123.rumba.sysclock;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.mscb.subject.ISubject;

/**
 * 系统时钟 | 订阅主题
 * @author lxm
 *
 */
public class SysclockSubject implements ISubject {
  
  private static final String CAPTION = "系统时钟";
  
  public static final String VALUE_EVENT_ONTICK = "ontick";
  private static String CAPTION_EVENT_ONTICK = "嘀嗒";
  private static String REMARK_EVENT_ONTICK = "系统时钟每次嘀嗒触发一次。";

  public String getCaption() throws BusinessException {
    return CAPTION;
  }

  public List<String> getEvents() throws BusinessException {
    return _getEvents();
  }

  public String getEventCaption(String event) throws BusinessException {
    return _getEventMap().get(event).caption;
  }

  public String getEventRemark(String event) throws BusinessException {
    return _getEventMap().get(event).remark;
  }
  
  private static List<String> events = null;
  
  private static List<String> _getEvents() {
    if (events == null) {
      events = new ArrayList();
      events.add(VALUE_EVENT_ONTICK);
    }
    return events;
  }
  
  private class EventRecord {
    public String caption;
    public String remark;
  }
  private static Map<String, EventRecord> eventMap = null;
  
  private Map<String, EventRecord> _getEventMap() {
    if (eventMap == null) {
      eventMap = new HashMap();
      EventRecord record = new EventRecord();
      record.caption = CAPTION_EVENT_ONTICK;
      record.remark = REMARK_EVENT_ONTICK;
      eventMap.put(VALUE_EVENT_ONTICK, record);
    }
    return eventMap;
  }
}
